// https://umijs.org/config/
import { defineConfig } from 'umi';
import defaultSettings from './defaultSettings';
import proxy from './proxy';
const { REACT_APP_ENV } = process.env;
export default defineConfig({
  hash: true,
  antd: {},
  dva: {
    hmr: true,
  },
  history: {
    type: 'browser',
  },
  locale: {
    // default zh-CN
    default: 'zh-CN',
    antd: true,
    // default true, when it is true, will use `navigator.language` overwrite default
    baseNavigator: true,
  },
  dynamicImport: {
    loading: '@/components/PageLoading/index',
  },
  targets: {
    ie: 11,
  },
  // umi routes: https://umijs.org/docs/routing
  routes: [
    {
      path: '/',
      component: '../layouts/BlankLayout',
      routes: [
        {
          path: '/',
          redirect: '/user/login',
        },
        {
          path: '/user',
          component: '../layouts/UserLayout',
          routes: [
            {
              path: '/user/login',
              name: 'login',
              component: './user/login',
            },
            {
              path: '/user',
              redirect: '/user/login',
            },
            {
              name: 'register-result',
              icon: 'smile',
              path: '/user/register-result',
              component: './user/register-result',
            },
            {
              name: 'register',
              icon: 'smile',
              path: '/user/register',
              component: './user/register',
            },
            {
              component: '404',
            },
          ],
        },
        {
          path: '403',
          name: '403',
          component: './exception/403',
        },
        {
          path: '404',
          name: '404',
          component: './exception/404',
        },
        {
          path: '500',
          name: '500',
          component: './exception/500',
        },
        {
          path: '/',
          component: '../layouts/BasicLayout',
          Routes: ['src/pages/Authorized'],
          authority: ['admin', 'user'],
          routes: [
            {
              name: 'home-page',
              icon: 'smile',
              path: '/home',
              component: './home/home-page',
            },
            {
              name: 'purchase',
              icon: 'highlight',
              path: '/purchase',
              routes: [
                {
                  path: '/',
                  redirect: '/purchase/purchase-apply',
                },
                {
                  name: 'purchase-apply',
                  icon: 'smile',
                  path: '/purchase/purchase-apply',
                  component: './purchase/purchase-apply',
                },
                {
                  name: 'purchase-approval',
                  icon: 'smile',
                  path: '/purchase/purchase-approval',
                  component: './purchase/purchase-approval',
                },
              ],
            },
            {
              name: 'material',
              icon: 'smile',
              path: '/material',
              component: './material/material-manage',
            },
            {
              name: 'product',
              icon: 'smile',
              path: '/product',
              component: './product/product-manage',
            },
            {
              name: 'client',
              icon: 'smile',
              path: '/partners',
              routes: [
                {
                  name: 'client',
                  icon: 'smile',
                  path: '/partners/customer',
                  component: './client/client-manage',
                },
                {
                  name: 'provider',
                  icon: 'smile',
                  path: '/partners/provider',
                  component: './client/provider-manage',
                },
              ]
            },
            {
              name: 'maintenance',
              icon: 'highlight',
              path: '/maintenance',
              routes: [
                {
                  path: '/',
                  redirect: '/maintenance/maintenance-manage',
                },
                {
                  name: 'maintenance-manage',
                  icon: 'smile',
                  path: '/maintenance/maintenance-manage',
                  component: './warehouse/warehouse-manage',
                },
                {
                  name: 'maintenance-history',
                  icon: 'smile',
                  path: '/maintenance/maintenance-history',
                  component: './warehouse/stock-material',
                },
                {
                  name: 'equipment-manage',
                  icon: 'smile',
                  path: '/maintenance/equipment-manage',
                  component: './warehouse/stock-product',
                },
                {
                  name: 'stock-mould',
                  icon: 'smile',
                  path: '/warehouse/stock-mould',
                  component: './warehouse/stock-mould',
                },
              ],
            },
            {
              name: 'order',
              icon: 'highlight',
              path: '/order',
              routes: [
                {
                  path: '/',
                  redirect: '/order/order-apply',
                },
                {
                  name: 'order-apply',
                  icon: 'smile',
                  path: '/order/order-apply',
                  component: './order/order-apply',
                },
                {
                  name: 'order-approval',
                  icon: 'smile',
                  path: '/order/order-approval',
                  component: './order/order-approval',
                },
                {
                  name: 'engineering-approval',
                  icon: 'smile',
                  path: '/order/engineering-approval',
                  component: './order/engineering-approval',
                },
                {
                  name: 'production-approval',
                  icon: 'smile',
                  path: '/order/production-approval',
                  component: './order/production-approval',
                },
                {
                  name: 'engineering-wo',
                  icon: 'smile',
                  path: '/order/engineering-wo',
                  component: './order/engineer-wo',
                },
                {
                  name: 'production-wo',
                  icon: 'smile',
                  path: '/order/production-wo',
                  component: './order/production-wo',
                },
                {
                  name: 'after-sale',
                  icon: 'smile',
                  path: '/order/after-sale',
                  component: './order/after-sale',
                },
              ],
            },
            {
              name: 'processing',
              icon: 'highlight',
              path: '/processing',
              routes: [
                {
                  path: '/',
                  redirect: '/processing/processing-manage',
                },
                {
                  name: 'processing-manage',
                  icon: 'smile',
                  path: '/processing/processing-manage',
                  component: './processing/processing-manage',
                },
                {
                  name: 'processing-history',
                  icon: 'smile',
                  path: '/processing/processing-history',
                  component: './processing/processing-history',
                },
                {
                  name: 'processing-flow-manage',
                  icon: 'smile',
                  path: '/processing/processing-flow-manage',
                  component: './processing/processing-flow-manage',
                },
                {
                  name: 'processing-wip',
                  icon: 'smile',
                  path: '/processing/processing-wip',
                  component: './processing/processing-wip',
                },
                {
                  name: 'processing-statistics',
                  icon: 'smile',
                  path: '/processing/processing-statistics',
                  component: './processing/processing-statistics',
                },
              ],
            },
            {
              name: 'finance',
              icon: 'highlight',
              path: '/finance',
              routes: [
                {
                  path: '/',
                  redirect: '/finance/processing-manage',
                },
                {
                  name: 'daily-statistics',
                  icon: 'smile',
                  path: '/finance/daily-statistics',
                  component: './finance/daily-statistics',
                },
                {
                  name: 'monthly-statistics',
                  icon: 'smile',
                  path: '/finance/monthly-statistics',
                  component: './finance/monthly-statistics',
                },
                {
                  name: 'payment-manage',
                  icon: 'smile',
                  path: '/finance/payment-manage',
                  component: './finance/payment-manage',
                },
                {
                  name: 'collection-manage',
                  icon: 'smile',
                  path: '/finance/collection-manage',
                  component: './finance/collection-manage',
                }
              ],
            },
            {
              name: 'system',
              icon: 'highlight',
              path: '/system',
              routes: [
                {
                  path: '/',
                  redirect: '/system/processing-manage',
                },
                {
                  name: 'department-manage',
                  icon: 'smile',
                  path: '/system/department-manage',
                  component: './system/department-manage',
                },
                {
                  name: 'service-manage',
                  icon: 'smile',
                  path: '/system/service-manage',
                  component: './system/employee-manage',
                },
                {
                  name: 'account-manage',
                  icon: 'smile',
                  path: '/system/account-manage',
                  component: './system/account-manage',
                },
                {
                  name: 'role-manage',
                  icon: 'smile',
                  path: '/system/role-manage',
                  component: './system/role-manage',
                },
              ],
            },
            {
              component: '404',
            },
          ],
        },
      ],
    },
  ],
  // Theme for antd: https://ant.design/docs/react/customize-theme-cn
  theme: {
    'primary-color': defaultSettings.primaryColor,
  },
  title: false,
  ignoreMomentLocale: true,
  proxy: proxy[REACT_APP_ENV || 'dev'],
  manifest: {
    basePath: '/',
  },
  esbuild: {},
});
